/**
 * 课程类
 * 包含课程基本信息和选课学生管理
 */
import java.util.ArrayList;
import java.util.List;

public class Course {
    private String id;             // 课程编号
    private String name;           // 课程名称
    private String location;       // 上课地点
    private String time;           // 上课时间
    private int credit;            // 学分
    private int capacity;          // 课程容量
    private List<Student> students;// 选课学生
    private Teacher teacher;       // 授课教师
    
    // 构造方法
    public Course(String id, String name, String location, String time, int capacity) {
        this.id = id;
        this.name = name;
        this.location = location;
        this.time = time;
        this.credit = 3;  // 默认3学分
        this.capacity = capacity;
        this.students = new ArrayList<>();
    }
    
    // 添加选课学生
    public boolean addStudent(Student student) {
        if (students.size() < capacity) {
            students.add(student);
            return true;
        }
        return false;
    }
    
    // 移除选课学生
    public void removeStudent(Student student) {
        students.remove(student);
    }
    
    // 设置授课教师
    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }
    
    // getter方法
    public String getId() {
        return id;
    }
    
    public String getName() {
        return name;
    }
    
    public String getLocation() {
        return location;
    }
    
    public String getTime() {
        return time;
    }
    
    public int getCredit() {
        return credit;
    }
    
    public int getCapacity() {
        return capacity;
    }
    
    public List<Student> getStudents() {
        return students;
    }
    
    public Teacher getTeacher() {
        return teacher;
    }
    
    // 设置学分
    public void setCredit(int credit) {
        this.credit = credit;
    }
}
